/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  							 script_adjust_cur_spell_points.cpp

	$Header: /heroes4/script_adjust_cur_spell_points.cpp $

	$NoKeywords: $

 ************************************************************************/

// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#include "precompiled.h"
#include "precompiled.h"
#pragma warning( disable: 4786 )

#include "script_adjust_cur_spell_points.h"

#include "basic_dialog.h"
#include "hero.h"

static bool g_adjusted_hero;

void t_script_increase_cur_spell_points::add_icons(t_basic_dialog* dialog) const
{
	if (g_adjusted_hero)
		dialog->add_spell_points(get_adjustment());
}

void t_script_increase_cur_spell_points::make_adjustment(t_adventure_map* map, t_hero* hero) const
{
	if (g_adjusted_hero = (hero != NULL)) {
		int target_points = hero->get_spell_points() + get_adjustment();
		int max_points = hero->get_maximum_spell_points();
		if (target_points > max_points)
			target_points = max_points;
		hero->set_spell_points( target_points );
	}
}

void t_script_decrease_cur_spell_points::add_icons(t_basic_dialog* dialog) const
{
	if (g_adjusted_hero)
		dialog->add_spell_points(-get_adjustment());
}

void t_script_decrease_cur_spell_points::make_adjustment(t_adventure_map* map, t_hero* hero) const
{
	if (g_adjusted_hero = (hero != NULL)) {
		int target_points = hero->get_spell_points() - get_adjustment();
		hero->set_spell_points( target_points < 0 ? 0 : target_points );
	}
}

